<template>
  <div>
    <!-- 头部 -->
    <div class="header">
      <div class="TLimg">
        <img src="../assets/tllogo.png" alt="" />
      </div>
      <slot></slot>
      <div class="searchbox">
        <a-input-search placeholder="搜索课程" size="large" @search="onSearch">
          <a-button slot="enterButton">
            <a-icon type="search" />
            搜索
          </a-button>
        </a-input-search>
      </div>

      <div class="lodinbox">
        <a-icon type="shopping-cart" class="shopping-cart" />
        <span>&nbsp;|&nbsp;</span>
        <!-- <span>&nbsp;{{msgList}}</span> -->
        <a-dropdown>
          <a
            class="ant-dropdown-link"
            @click="(e) => e.preventDefault()"
            style="color: black"
          >
            {{ msgList }} <a-icon type="down" />
          </a>
          <a-menu slot="overlay">
            <a-menu-item>
              <router-link to="index"
                ><a href="javascript:;">退出登录</a>
              </router-link>
              <!-- <a href="javascript:;">退出登录</a> -->
            </a-menu-item>
          </a-menu>
        </a-dropdown>
        <img style="width: 30px; height: 30px" :src="mineImg" alt="" />
      </div>
    </div>
    <!-- 个人中心 -->
    <section class="center">
      <div class="personalCenter">
        <div id="centerTabContent" class="tab-content">
          <!-- 我的主页 -->
          <div class="tab-pane fade in active" id="normalLogin">
            <p>个人信息</p>
            <ul>
              <li class="nickname">
                <p>昵称</p>
                <span data-toggle="modal" data-target="#nickname"> 修改</span>
                <h3>{{ msgList }}</h3>
              </li>
              <li class="peoplePhone">
                <p>手机号</p>
                <span data-toggle="modal" data-target="#peoplePhone">
                  修改</span
                >
                <h3>{{ phone }}</h3>
              </li>
              <li class="peoplePsw">
                <p>密码</p>
                <span data-toggle="modal" data-target="#peoplePsw"> 修改</span>
                <h3>******</h3>
              </li>
            </ul>
            <div class="avatar">
              <!-- <input type="file" id="filebtn">
            <button type="button" onClick="alertFile()" class="filebtn">更改头像</button> -->
              <!-- <div><img style="width:200px ; height:200px" :src="avatarUrl" alt=""></div> -->
              <a-upload
                name="file"
                :multiple="true"
                action="/api/pcUser/updata/userAvatar"
                :headers="headers"
                @change="handleChange"
                :show-upload-list="false"
              >
                <a-button style="width: 110px; margin-bottom: 20px">
                  <a-icon type="upload" />更改头像</a-button
                >

                <div>
                  <img
                    style="width: 200px; height: 200px"
                    :src="avatarUrl"
                    alt=""
                  />
                </div>
              </a-upload>
              <!-- <div ><img style="width:200px ; height:200px" :src="avatarUrl" alt=""></div> -->
            </div>
          </div>
        </div>
      </div>
    </section>
    <div></div>
  </div>
</template>
<script>
import { getUserMsg } from "../api/api";
export default {
  name: "minePage",
  data() {
    return {
      msgList: "",
      phone: "",
      // 上传头像
      headers: {
        authorization: "authorization-text",
        avatarUrl: "",
        mineImg: "",
      },
    };
  },
  created() {
    // console.log(this.$route.query);

    // this.mineImg=this.$route.query.avatarUrl
    getUserMsg().then((res) => {
      this.msgList = res.userInfo.nickname;
      this.phone = res.userInfo.mobile;
      this.avatarUrl = res.userInfo.avatarUrl;
      this.mineImg = res.userInfo.avatarUrl;
    });
  },
  methods: {
    // 上传头像
    handleChange(info) {
      if (info.file.status !== "uploading") {
        console.log(info.file, info.fileList);
      }

      if (info.file.status === "done") {
        this.$message.success(`${info.file.response.msg} `);
        this.avatarUrl = info.file.response.userInfo.avatarUrl;
      } else if (info.file.status === "error") {
        this.$message.error(`${info.file.name} file upload failed.`);
      }
    },
  },
};
</script>
<style scoped lang="less">
.header {
  margin: auto;
  width: 1200px;
  height: 106px;
}
.TLimg {
  float: left;
  width: 179px;
  height: 55px;
  margin-top: 22px;
  margin-right: 200px;
}
// /deep/.ant-input-wrapper {
//     height: 60px;
//     width: 100%;
// }
/deep/.ant-input {
  border-radius: 19px 0 0 19px;
  height: 38px;
}
/deep/.ant-btn {
  width: 90px;
  height: 38px;
  border-radius: 0 19px 19px 0;
  background-color: #1da57a;
  color: #fff;
}
.searchbox {
  float: left;
  margin-top: 30px;
  width: 400px;
  height: 38px;
}
.lodinbox {
  float: right;
  margin-top: 30px;
  width: 170px;
  height: 34px;
  line-height: 34px;
  // background-color: red;
}
.lodinbox > span:nth-of-type(1) {
  font-size: 20px;
  color: #999;
}
.lodinbox > span:nth-of-type(2) {
  font-size: 14px;
}
.lodinbox > span:nth-of-type(3) {
  display: inline-block;
  width: 32px;
  height: 32px;
  background-color: #ccc;
  border-radius: 16px;
}
.shopping-cart {
  font-size: 20px;
  color: #999;
}
.user {
  font-size: 16px;
  color: #fff;
}
.navlist {
  width: 1200px;
}
.head-nav {
  position: relative;
  margin: auto;
  width: 1200px;
  height: 30px;
}
.headlist {
  overflow: hidden;
  position: relative;
}
.headlist > li {
  float: left;
  margin: 0 30px 0 0;
  font-size: 16px;
}
/* .headlist>li:hover {
    color: #00cf8c;
} */
ul {
  list-style: none;
}
.center {
  padding: 20px 10px;
  background-color: #f4f4f4;
}
.personalCenter {
  margin: 0 auto;
  width: 1200px;
  background-color: #fff;
  overflow: hidden;
  padding: 20px;
}
#centerTab {
  float: left;
  height: 100%;
  border-right: 1px solid #ccc;
}
.nav-tabs > li.active {
  border-right: 1px solid red;
}
.nav-tabs > li.active > a {
  border: 0;
}
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
  border: 0;
}
#centerTabContent {
  float: left;
  width: 90%;
  padding: 6px 20px;
}
#normalLogin {
  width: 100%;
}
#normalLogin > p {
  font-size: 22px;
  color: rgba(0, 0, 0, 0.65);
}
#normalLogin > ul {
  padding: 40px;
  font-size: 20px;
  color: #333;
  line-height: 40px;
}
#normalLogin > ul > li {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid #ddd;
}
#normalLogin > ul > li > p {
  display: inline-block;
}
#normalLogin > ul > li > span {
  font-size: 14px;
  color: #00cf8c;
  cursor: pointer;
}
#normalLogin > .avatar {
  margin-left: 40px;
}
#normalLogin > .avatar > .pic {
  width: 200px;
  height: 200px;
  background-color: azure;
  margin-bottom: 30px;
  outline: 0;
  display: block;
  border: 0;
}
#normalLogin > .avatar > button {
  text-align: center;
  width: 110px;
  height: 32px;
  line-height: 32px;
  font-size: 14px;
  border-radius: 2px;
  color: rgba(0, 0, 0, 0.65);
  background-color: #fff;
  border: 1px solid #c4c4c4;
}
#normalLogin > .avatar > button:hover {
  border-color: #00cf8c;
  color: #00cf8c;
}
/* 修改昵称 */
#nickname .nickname_body {
  padding: 20px;
}
#nickname .nickname_body > div {
  border: 1px solid rgb(168, 168, 168);
  height: 34px;
  line-height: 32px;
  padding-left: 10px;
}
#nickname .nickname_body > div:hover {
  border-color: #00cf8c;
}
#nickname .nickname_body input {
  border: 0;
  outline: 0;
}
/* 修改手机号 */
.peoplePhone_body > div,
.peoplePsw_body > div {
  border: 1px solid rgb(168, 168, 168);
  height: 34px;
  line-height: 32px;
  padding-left: 10px;
  margin-bottom: 20px;
}
#peoplePhone .peoplePhone_body > div:hover {
  border-color: #00cf8c;
}
.peoplePhone_body input,
.peoplePsw_body input {
  width: 100%;
  border: 0;
  outline: 0;
}
.peoplePhone_body button,
.peoplePsw_body button {
  width: 102px;
  height: 32px;
  color: #fff;
  background-color: #00cf8c;
  border-color: #00cf8c;
  border: 0;
}
/* 修改密码 */
.peoplePsw_body {
  padding: 20px 30px;
}
.peoplePsw_body > div:nth-child(5) {
  width: 50%;
  display: inline-block;
}
#peoplePsw .peoplePsw_body > div:hover {
  border-color: #00cf8c;
}
.modal-dialog {
  width: 500px;
}
.peoplePsw_body button {
  margin-left: 40px;
}
</style>
